//index.js

//var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
var zhuan_dingwei = require('../../libs/dingwei.js');
//获取应用实例
const app = getApp()
Page({
  data: {
    //默认未获取地址
    hasLocation: false,
    info:'',
    longitude:'',
    latitude:''
  },
  getlocal_dingweui:function(e){
    var that=this;
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
        that.setData({
          longitude : res.longitude,
         latitude : res.latitude
        })
        console.log(that.data.longitude)
        console.log(that.data.latitude)
        var gcj02tobd09 = zhuan_dingwei.wgs84togcj02(that.data.longitude, that.data.latitude);
        console.log(gcj02tobd09);
        that.setData({
          longitude: gcj02tobd09[0],
          latitude: gcj02tobd09[1]
        })
        console.log('-------')
        that.get_baidu_dingwei()
      }
    })
  },
  onLoad: function () {
   this.getlocal_dingweui();
 
  }, 
  get_baidu_dingwei:function(){
    console.log('-----------')
    var that = this;
    console.log(that.data.longitude)
    console.log(that.data.latitude)
   
    wx.request({
      url: 'https://baoxian.grwlkj.com/home/index/get_user_city',
      method: 'get',
      data: {
        longitude: that.data.longitude,
        latitude: that.data.latitude
      },
      success(res) {
        console.log("res", res)
        var info = res.data.data
        that.setData({
          info: info,
        })
      }
    })
  },
  onShow: function () {
    // 调用接口
  }
})



